const core = require('@babel/core') // es6和es5的转化
const traverse = require('@babel/traverse').default // 节点遍历
const parser = require('@babel/parser') // 转化ast树

module.exports = function (content, map, meta) {
  const ast = parser.parse(content, {
    sourceType: 'module' /*解析es模块*/
  })
  traverse(ast, {
    Identifier({node}) {
      console.log('node', node.value)
    },
    StringLiteral({node}) {
      console.log(node.value)
    }
  })
  const resCode = core.transformFromAstSync(ast)

  return resCode.code
};

module.exports.pitch = function (remainingRequest, precedingRequest, data) {
  data.value = 12345;
};
